package grex.Nodes;

import grex.Data.PredictionContainer;

public class Plus extends Node implements IContinuousOperator{
  private static final int NROFCILDREN = 2;

  public Plus() {
    super(NROFCILDREN);
  }

  public synchronized void execute(Node parent,PredictionContainer data,int mode) throws GeneException {
      this.parent = parent;

    Node[] childs = this.getChildren();
    PredictionContainer lResult = data;
    PredictionContainer rResult = data.clone();
    childs[0].execute(this, lResult, mode);
    childs[1].execute(this, rResult, mode);
        for (double[] key : data.keySet()) {
                data.get(key).setPrediction(lResult.get(key).getPrediction() + rResult.get(key).getPrediction());
        }

  }

  public Object clone() {
    Plus newGreater = new Plus();
    newGreater.setOptions(ops);
    cloneChildren(newGreater);
    newGreater.setParent(parent);
     return newGreater;
  }
  public String toString() {
    return "+";
  }

}
